package org.ReportDesigner.reportModel;

import org.ReportDesigner.configurator.Configuration;
import org.ReportDesigner.controlModel.Type;
import com.itextpdf.text.*;
import org.apache.log4j.Logger;

import java.util.LinkedList;
import java.util.List;

@Type(type = "mixed", subType = "reportFooter", name = "rfooter")
public class ReportFooter extends ReportElement {
    private static final Logger log = Logger.getLogger(ReportFooter.class);
    private String textReportFooter;


    @Override
    public String getText() {
        return textReportFooter;
    }

    @Override
    public void setText(String text) {
        this.textReportFooter = text;
    }



    @Override
    public List<Element> addTo(Configuration configuration) {
        List<Element> elementList = new LinkedList<Element>();
        if (!this.getText().isEmpty()){
            Phrase phrase = new Phrase(this.getText(),
                    FontFactory.getFont(configuration.getFont(), configuration.getFontEncoding()));
            elementList.add(phrase);
        }
        if (!this.getBody().isEmpty()){
            for (ReportElement repElement: this.getBody()){
                elementList.addAll(repElement.addTo(configuration));
            }
        }
        return elementList;
    }
}


